package creator.factory.factoryMethod;



/**
 * 增加咖啡种类的时候，确实需要增加相应的工场和咖啡实现类，但是这些都是新增的，没有改变原来的代码，
 */
public class Client {
    public static void main(String[] args) {
        //创建咖啡店对象
        CoffeeStore store = new CoffeeStore();
        //创建对象
        //CoffeeFactory factory = new AmericanCoffeeFactory();
        CoffeeFactory factory = new LatteCoffeeFactory();
        store.setFactory(factory);
        //点咖啡
        Coffee coffee = store.orderCoffee();
        System.out.println(coffee.getName());

        DessertStore dessertStore = new DessertStore();
        AmericanCoffeeFactory americanCoffeeFactory = new AmericanCoffeeFactory();
        dessertStore.setFactory(americanCoffeeFactory);
        //点咖啡
        Coffee coffee2 = dessertStore.orderCoffee();
        System.out.println(coffee2.getName());
    }
}
